package seueniumfordemoiselle.seleniumsimplify.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

/**
 * @author rogerio
 * Representa a p�gina de cadastro de UF
 *
 */
public class UFCadastroPage extends BasePage{
	
	WebElement inputNome;
	
	WebElement inputSigla;
	
	WebElement linkInserir;
	
	WebElement linkVoltar;
	
	WebElement linkAlterar;
	
	WebElement linkApagar;
	
	WebElement spanMensagem;

	public UFCadastroPage(WebDriver driver) {
		super(driver);
	}
	
	public WebDriver getDriver() {
		return driver;
	}

	public void setDriver(WebDriver driver) {
		this.driver = driver;
	}
	
	private void pegarInputNome() {
		this.inputNome = this.driver.findElement(By.xpath("//input[contains(@id,'nome')]"));;
	}
	
	private void pegarInputSigla() {
		this.inputSigla = this.driver.findElement(By.xpath("//input[contains(@id,'sigla')]"));;
	}
	
	public void clicarLinkInserir(){
		driver.findElement(By.xpath("//a[contains(text(),'Inserir')]")).click();	
	}
	
	public void clicarLinkVoltar(){
		driver.findElement(By.xpath("//a[contains(text(),'Voltar')]")).click();		
	}
	
	public void clicarLinkAlterar(){
		driver.findElement(By.xpath("//a[contains(text(),'Alterar')]")).click();		
	}
	
	public void clicarLinkApagar(){
		driver.findElement(By.xpath("//a[contains(text(),'Apagar')]")).click();		
	}
	
	/**
	 * Preenche o campo Nome 
	 */
	public void digitarNome(String string){
		if (this.inputNome == null){
			this.pegarInputNome();
		}
		this.inputNome.clear();
		this.inputNome.sendKeys(string);
	}
	
	
	/**
	 * Clica no bot�o Novo
	 */
	public void clicarNovo(){
	
		driver.findElement(By.xpath("//*[@value='Novo']")).click();
	}


	/**
	 * Preenche o campo Sigla 
	 */
	public void digitarSigla(String string) {
		if (this.inputSigla == null){
			this.pegarInputSigla();
		}
		this.inputSigla.clear();
		this.inputSigla.sendKeys(string);		
	}	
}
